Different outputs

html document

---    
title: "rmarkdown_pdf"    
author: "Sébastien Renaut"    
date: '2018-09-06'    
output: 
  html_document: 
    toc: yes 
    theme: cerulean 
--- 

Microsoft Word

---  
title: "rmarkdown_docx"  
author: "Sébastien Renaut"  
date: '2018-09-06'  
output: 
  word_document: 
    toc: yes
---   
  • You can specify it when you create a new Rmarkdown document.

  • You can also specify it later in the header.

  • Then, it’s just a matter of kniting the document!

  • Little documentation, few options & configurations are possible (This is probably not the format that should be promoted, as it moves away from an open source environment).

  • Can specify a LibreOffice OpenDocument Text (output: odt_document) or Rich Text Format (output: rtf_document) instead

  • FYI, there is a spellchecker in Rstudio: Edit >Check Spelling…

Portable Document Format (.pdf)

---    
title: "rmarkdown_pdf"    
author: "Sébastien Renaut"    
date: '2018-09-06'    
output: 
  pdf_document:
    keep_tex: true
    toc: yes  
---    
  • You need an extra step to go from a LaTeX (.tex) format to a .pdf. This is handled by the R markdown pdf_document function in R.

  • LaTeX software is a high-quality typesetting system.

  • It is the de facto standard for the communication and publication of scientific documents.

  • LaTeX is available as free software here.

  • If interested, follow this discussion: Why LaTeX is such a bloated system?

  • So…TinyTeX is a custom LaTeX distribution that is small in size (~150MB) but functions well in most cases, especially for R users .

  • tinytex R package is a wrapper function that installs TinyTeX.

Exercice 1

  • If you haven’t done so, install the tinytex R package from the console and run install_tinytex(). It may take a few minutes to download and compile (~150MB).
install.packages("tinytex")  
library(tinytex)  
install_tinytex()  
  • Create a new document, compile it as .pdf.
    • Add a Table of Content.
    • Add a graphic.
  • Now compile it as a Word document (.docx)

  • Add some reference by specifying the csl: ../csl/peerj.csl and bibliography: ../biblio/test_library.bib in the header

LaTeX template

  • This allows further options in the .Rmd file when going from .tex file to .pdf.

  • You can build your own .tex template if you know LaTeX…

  • There are many templates available on the web that you can use.

  • Here is one I like for manuscripts (Thanks svmiller on )

    • For example, using this (sligthly modified) template, I am writing my first .Rmd manuscript.
       

       
       
  • Here is one I like for Curriculum Vitae
    • For example, using this template, I re-wrote my CV to give it a fresh look!
       
       
       
  • Download and save template. Refer to it in the header. (Note however that you should download or at least take a look at the .Rmd to see options available, and .pdf to see output.)

--- 
output:  
  pdf_document:  
   keep_tex: true  
   fig_caption: true  
   latex_engine: pdflatex  
   template: ../reference_material/svm-latex-ms.tex        
title: "**This is my first Rmarkdown manuscript**  
#many more options can go here which will be using by pdflatex.
---   
  • You should know have all the tools to generate your fully reproducible manuscripts in R.

  • The only real objection I see in formatting manuscript this way is integrating comments from co-authors who do not use R, R markdown, git or github.

Exercice 2

  • R packages rticles is (potentially) a nice package to format articles according to the specification of a journal.

  • But first, you need to install it in the R console.

  • Once installed, try starting a new R markdown document according to your journal of interest.


 

 

  • Right now, few templates available.

  • Some templates may be slower to render (e.g PNAS), depending on what LaTeX package they depend on and need to be downloaded.

Other possibilities

Presentations

---
title: "Untitled"
author: "Sebastien Renaut"
date: "27/02/2019"
output: ioslides_presentation
---
  • You can also generate Powerpoint-like presentations.

Overleaf

  • Overleaf is an online LaTeX and Rich Text collaborative writing and publishing tool that makes the whole process of writing, editing and publishing scientific documents much quicker and easier.

  • Remember this:

  • You can generate your .tex file, upload it to a github repo and Overleaf will connect to it. Others can then collaborate and modify the .tex file via overleaf platform.

  • Let’s take a quick look at overleaf. Once you have an overleaf account, you can connect it to a github repository and .tex document. You can then pull/push from overleaf to github, allowing others to modify your .tex file.

Bookdown

  • Bookdown is an open-source R package that facilitates writing books and long-form articles/reports with R Markdown.

Radix

  • Radix offers a better look for publishing blog, webpages, adapted to mobile devices.

  • Note that in future version, Radix is now called distill

install.packages("radix")  
install.packages("leaflet")  
  • Change output in header to:
---  
title: "Rmarkdown: radix"  
author: "Sébastien Renaut"  
output: radix::radix_article  
---  
  • Then you can start playing with the radix options, such as in this example below (full width figures):
#Note that you may need to set eval = F for some formats (pdf, docx) to compile properly

```{r radix_example, echo = F, eval = T, layout='l-screen-inset'}  
library(leaflet)  
leaflet() %>%  
addTiles() %>%   
addMarkers(lng=174.768, lat=-36.852,popup="The birthplace of R")  
```    

Exercice 3

  • Use a previously generate document to generate a radix html output.

  • What does it look like? Better?